import 'package:flutter/material.dart';
import '../model/post.dart';

class CardDemo extends StatefulWidget {
  @override
  _CardDemoState createState() => _CardDemoState();
}
class _CardDemoState extends State<CardDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title:Text('CardDemo'),
          elevation: 0.0,
        ),
        body: Container(
         padding: EdgeInsets.all(10),
         child: ListView(
           children: posts.map((post){
             return Card(
                  child: Column(
                    children: [
                     AspectRatio(
                       aspectRatio: 16/9,
                       child: ClipRRect(
                         borderRadius: BorderRadius.only(
                           topLeft: Radius.circular(4),
                           topRight: Radius.circular(4)
                         ),
                          child: Image.network(
                            post.imageUrl,
                            fit:BoxFit.cover
                         )
                       ),
                     ),
                     ListTile(
                       leading: CircleAvatar(
                         backgroundImage:NetworkImage(post.imageUrl)
                       ),
                      title: Text(post.title),
                      subtitle:Text(post.author),
                     ),
                     Container(
                       padding: EdgeInsets.all(20),
                       child: Text(post.description,maxLines: 2,overflow:TextOverflow.ellipsis),
                     ),
                  ButtonTheme.bar(
                    child:ButtonBar(
                      children: [
                        FlatButton(
                          onPressed:(){}, 
                          child: Text('Like'.toUpperCase())
                          ),
                        FlatButton(
                          onPressed:(){}, 
                          child: Text('Read'.toUpperCase())
                          )
                      ],
                    ),
                  ),
                     
                    ],
                  ),
             );
           }).toList(),
         ),
        ),
    );
  }
}